<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org">

  <title>Standard C String and Character</title>
  <link href="../cppreference.css" rel="stylesheet" type="text/css">
</head>

<body>
<table>
  <tr>
  <td>
  <div class="body-content">

  <div class="header-box">
    <a href="../index.html">cppreference.com</a> &gt; <a href=
    "index.html">Standard C String and Character</a>
  </div>

  <div class="name-format">
    atof
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;stdlib.h&gt;
  double atof( const char *str );
</pre>

  <p>The function atof() converts <em>str</em> into a double, then
  returns that value. <em>str</em> must start with a valid number, but
  can be terminated with any non-numerical character, other than
  &quot;E&quot; or &quot;e&quot;. For example,</p>
  <pre class="example-code">
   x = atof( &quot;42.0is_the_answer&quot; );           
</pre>

  <p>results in x being set to 42.0.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="atoi.html">atoi</a><br>
    <a href="atol.html">atol</a><br>
    (Standard C I/O) <a href="../stdio/sprintf.html">sprintf</a><br>
    <a href="strtod.html">strtod</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>
<hr>
<hr>

  <div class="name-format">
    atoi
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;stdlib.h&gt;
  int atoi( const char *str );
</pre>

  <p>The atoi() function converts <em>str</em> into an integer, and
  returns that integer. <em>str</em> should start with whitespace or
  some sort of number, and atoi() will stop reading from <em>str</em>
  as soon as a non-numerical character has been read.  For example:</p>

  <pre class="example-code">
  int i;
  i = atoi( &quot;512&quot; );
  i = atoi( &quot;512.035&quot; );
  i = atoi( &quot;   512.035&quot; );
  i = atoi( &quot;   512+34&quot; );
  i = atoi( &quot;   512 bottles of beer on the wall&quot; );
</pre>

  <p>All five of the above assignments to the variable <em>i</em> would
  result in it being set to 512.</p>

  <p>If the conversion cannot be performed, then atoi() will return
  zero:</p>
  <pre class="example-code">
  int i = atoi( &quot; does not work: 512&quot; );  // results in i == 0
</pre>

  <p>You can use <a href= "../stdio/sprintf.html">sprintf</a>() to
  convert a number into a string.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="atof.html">atof</a><br>
    <a href="atol.html">atol</a><br>
    (Standard C I/O) <a href="../stdio/sprintf.html">sprintf</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    atol
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;stdlib.h&gt;
  long atol( const char *str );
</pre>

  <p>The function atol() converts <em>str</em> into a long, then
  returns that value. atol() will read from <em>str</em> until it finds
  any character that should not be in a long. The resulting truncated
  value is then converted and returned. For example,</p>
  <pre class="example-code">
   x = atol( &quot;1024.0001&quot; );           
</pre>

  <p>results in x being set to 1024L.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="atof.html">atof</a><br>
    <a href="atoi.html">atoi</a><br>
    (Standard C I/O) <a href="../stdio/sprintf.html">sprintf</a><br>
    <a href="strtol.html">strtol</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    isalnum
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;ctype.h&gt;
  int isalnum( int ch );
</pre>

  <p>The function isalnum() returns non-zero if its argument is a
  numeric digit or a letter of the alphabet. Otherwise, zero is
  returned.</p>
  <pre class="example-code">
   char c;
   scanf( &quot;%c&quot;, &amp;c );
   if( isalnum(c) )
     printf( &quot;You entered the alphanumeric character %c\n&quot;, c );              
</pre>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="isalpha.html">isalpha</a><br>
    <a href="iscntrl.html">iscntrl</a><br>
    <a href="isdigit.html">isdigit</a><br>
    <a href="isgraph.html">isgraph</a><br>
    <a href="isprint.html">isprint</a><br>
    <a href="ispunct.html">ispunct</a><br>
    <a href="isspace.html">isspace</a><br>
    <a href="isxdigit.html">isxdigit</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    isalpha
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;ctype.h&gt;
  int isalpha( int ch );
</pre>

  <p>The function isalpha() returns non-zero if its argument is a
  letter of the alphabet. Otherwise, zero is returned.</p>
  <pre class="example-code">
   char c;
   scanf( &quot;%c&quot;, &amp;c );
   if( isalpha(c) )
     printf( &quot;You entered a letter of the alphabet\n&quot; );              
</pre>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="isalnum.html">isalnum</a><br>
    <a href="iscntrl.html">iscntrl</a><br>
    <a href="isdigit.html">isdigit</a><br>
    <a href="isgraph.html">isgraph</a><br>
    <a href="isprint.html">isprint</a><br>
    <a href="ispunct.html">ispunct</a><br>
    <a href="isspace.html">isspace</a><br>
    <a href="isxdigit.html">isxdigit</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    iscntrl
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;ctype.h&gt;
  int iscntrl( int ch );
</pre>

  <p>The iscntrl() function returns non-zero if its argument is a
  control character (between 0 and 0x1F or equal to 0x7F). Otherwise,
  zero is returned.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="isalnum.html">isalnum</a><br>
    <a href="isalpha.html">isalpha</a><br>
    <a href="isdigit.html">isdigit</a><br>
    <a href="isgraph.html">isgraph</a><br>
    <a href="isprint.html">isprint</a><br>
    <a href="ispunct.html">ispunct</a><br>
    <a href="isspace.html">isspace</a><br>
    <a href="isxdigit.html">isxdigit</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    isdigit
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;ctype.h&gt;
  int isdigit( int ch );
</pre>

  <p>The function isdigit() returns non-zero if its argument is a digit
  between 0 and 9. Otherwise, zero is returned.</p>
  <pre class="example-code">
   char c;
   scanf( &quot;%c&quot;, &amp;c );
   if( isdigit(c) )
     printf( &quot;You entered the digit %c\n&quot;, c );               
</pre>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="isalnum.html">isalnum</a><br>
    <a href="isalpha.html">isalpha</a><br>
    <a href="iscntrl.html">iscntrl</a><br>
    <a href="isgraph.html">isgraph</a><br>
    <a href="isprint.html">isprint</a><br>
    <a href="ispunct.html">ispunct</a><br>
    <a href="isspace.html">isspace</a><br>
    <a href="isxdigit.html">isxdigit</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    isgraph
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;ctype.h&gt;
  int isgraph( int ch );
</pre>

  <p>The function isgraph() returns non-zero if its argument is any
  printable character other than a space (if you can see the character,
  then isgraph() will return a non-zero value). Otherwise, zero is
  returned.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="isalnum.html">isalnum</a><br>
    <a href="isalpha.html">isalpha</a><br>
    <a href="iscntrl.html">iscntrl</a><br>
    <a href="isdigit.html">isdigit</a><br>
    <a href="isprint.html">isprint</a><br>
    <a href="ispunct.html">ispunct</a><br>
    <a href="isspace.html">isspace</a><br>
    <a href="isxdigit.html">isxdigit</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    islower
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;ctype.h&gt;
  int islower( int ch );
</pre>

  <p>The islower() function returns non-zero if its argument is a
  lowercase letter. Otherwise, zero is returned.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="isupper.html">isupper</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    isprint
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;ctype.h&gt;
  int isprint( int ch );
</pre>

  <p>The function isprint() returns non-zero if its argument is a
  printable character (including a space). Otherwise, zero is
  returned.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="isalnum.html">isalnum</a><br>
    <a href="isalpha.html">isalpha</a><br>
    <a href="iscntrl.html">iscntrl</a><br>
    <a href="isdigit.html">isdigit</a><br>
    <a href="isgraph.html">isgraph</a><br>
    <a href="ispunct.html">ispunct</a><br>
    <a href="isspace.html">isspace</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    ispunct
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;ctype.h&gt;
  int ispunct( int ch );
</pre>

  <p>The ispunct() function returns non-zero if its argument is a
  printing character but neither alphanumeric nor a space. Otherwise,
  zero is returned.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="isalnum.html">isalnum</a><br>
    <a href="isalpha.html">isalpha</a><br>
    <a href="iscntrl.html">iscntrl</a><br>
    <a href="isdigit.html">isdigit</a><br>
    <a href="isgraph.html">isgraph</a><br>
    <a href="isprint.html">isprint</a><br>
    <a href="isspace.html">isspace</a><br>
    <a href="isxdigit.html">isxdigit</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    isspace
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;ctype.h&gt;
  int isspace( int ch );
</pre>

  <p>The isspace() function returns non-zero if its argument is some
  sort of space (i.e. single space, tab, vertical tab, form feed,
  carriage return, or newline). Otherwise, zero is returned.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="isalnum.html">isalnum</a><br>
    <a href="isalpha.html">isalpha</a><br>
    <a href="iscntrl.html">iscntrl</a><br>
    <a href="isdigit.html">isdigit</a><br>
    <a href="isgraph.html">isgraph</a><br>
    <a href="isprint.html">isprint</a><br>
    <a href="ispunct.html">ispunct</a><br>
    <a href="isxdigit.html">isxdigit</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    isupper
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;ctype.h&gt;
  int isupper( int ch );
</pre>

  <p>The isupper() function returns non-zero if its argument is an
  uppercase letter. Otherwise, zero is returned.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="islower.html">islower</a><br>
    <a href="tolower.html">tolower</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    isxdigit
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;ctype.h&gt;
  int isxdigit( int ch );
</pre>

  <p>The function isxdigit() returns non-zero if its argument is a
  hexidecimal digit (i.e. A-F, a-f, or 0-9). Otherwise, zero is
  returned.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="isalnum.html">isalnum</a><br>
    <a href="isalpha.html">isalpha</a><br>
    <a href="iscntrl.html">iscntrl</a><br>
    <a href="isdigit.html">isdigit</a><br>
    <a href="isgraph.html">isgraph</a><br>
    <a href="ispunct.html">ispunct</a><br>
    <a href="isspace.html">isspace</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    memchr
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  void *memchr( const void *buffer, int ch, size_t count );
</pre>

  <p>The memchr() function looks for the first occurrence of
  <em>ch</em> within <em>count</em> characters in the array pointed to
  by <em>buffer</em>. The return value points to the location of the
  first occurrence of <em>ch</em>, or <strong>NULL</strong> if
  <em>ch</em> isn&#39;t found. For example:</p>
  <pre class="example-code">
   char names[] = &quot;Alan Bob Chris X Dave&quot;;
   if( memchr(names,&#39;X&#39;,strlen(names)) == <strong>NULL</strong> )
     printf( &quot;Didn&#39;t find an X\n&quot; );
   else
     printf( &quot;Found an X\n&quot; );                
</pre>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="memcmp.html">memcmp</a><br>
    <a href="memcpy.html">memcpy</a><br>
    <a href="strstr.html">strstr</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    memcmp
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  int memcmp( const void *buffer1, const void *buffer2, size_t count );
</pre>

  <p>The function memcmp() compares the first <em>count</em> characters
  of <em>buffer1</em> and <em>buffer2</em>. The return values are as
  follows:</p>

  <table class="code-table">
    <tr>
      <th class="code-table-th">Value</th>

      <th class="code-table-th">Explanation</th>
    </tr>

    <tr>
      <td class="code-table-td">less than 0</td>

      <td class="code-table-td">buffer1 is less than buffer2</td>
    </tr>

    <tr>
      <td class="code-table-td">equal to 0</td>

      <td class="code-table-td">buffer1 is equal to buffer2</td>
    </tr>

    <tr>
      <td class="code-table-td">greater than 0</td>

      <td class="code-table-td">buffer1 is greater than buffer2</td>
    </tr>
  </table>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="memchr.html">memchr</a><br>
    <a href="memcpy.html">memcpy</a><br>
    <a href="memset.html">memset</a><br>
    <a href="strcmp.html">strcmp</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    memcpy
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  void *memcpy( void *to, const void *from, size_t count );
</pre>

  <p>The function memcpy() copies <em>count</em> characters from the
  array <em>from</em> to the array <em>to</em>. The return value of
  memcpy() is <em>to</em>. The behavior of memcpy() is undefined if
  <em>to</em> and <em>from</em> overlap.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="memchr.html">memchr</a><br>
    <a href="memcmp.html">memcmp</a><br>
    <a href="memmove.html">memmove</a><br>
    <a href="memset.html">memset</a><br>
    <a href="strcpy.html">strcpy</a><br>
    <a href="strlen.html">strlen</a><br>
    <a href="strncpy.html">strncpy</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    memmove
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  void *memmove( void *to, const void *from, size_t count );
</pre>

  <p>The memmove() function is identical to <a href=
  "memcpy.html">memcpy</a>(), except that it works even if <em>to</em>
  and <em>from</em> overlap.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="memcpy.html">memcpy</a><br>
    <a href="memset.html">memset</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    memset
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  void* memset( void* buffer, int ch, size_t count );
</pre>

  <p>The function memset() copies <em>ch</em> into the first
  <em>count</em> characters of <em>buffer</em>, and returns
  <em>buffer</em>. memset() is useful for intializing a section of
  memory to some value. For example, this command:</p>

  <pre class="example-code">
   memset( the_array, &#39;\0&#39;, sizeof(the_array) );                
</pre>

  <p>...is a very efficient way to set all values of the_array to
  zero.</p>  

  <p>The table below compares two different methods for initializing
  an array of characters: a for-loop versus memset().  As the size of the
  data being initialized increases, memset() clearly gets the job done
  much more quickly:</p>

  <table class="misc-table">
    <tr class="misc-table-tr-1">
      <th>Input size</th>
      <th>Initialized with a for-loop</th>
      <th>Initialized with memset()</th>
    </tr>

    <tr class="misc-table-tr-2">
      <td>1000</td>
      <td>0.016</td>
      <td>0.017</td>
    </tr>

    <tr class="misc-table-tr-1">
      <td>10000</td>
      <td>0.055</td>
      <td>0.013</td>
    </tr>

    <tr class="misc-table-tr-2">
      <td>100000</td>
      <td>0.443</td>
      <td>0.029</td>
    </tr>

    <tr class="misc-table-tr-1">
      <td>1000000</td>
      <td>4.337</td>
      <td>0.291</td>
    </tr>
  </table>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="memcmp.html">memcmp</a><br>
    <a href="memcpy.html">memcpy</a><br>
    <a href="memmove.html">memmove</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strcat
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  char *strcat( char *str1, const char *str2 );
</pre>

  <p>The strcat() function concatenates <em>str2</em> onto the end of
  <em>str1</em>, and returns <em>str1</em>. For example:</p>
  <pre class="example-code">
   printf( &quot;Enter your name: &quot; );
   scanf( &quot;%s&quot;, name );
   title = strcat( name, &quot; the Great&quot; );
   printf( &quot;Hello, %s\n&quot;, title );            
</pre>

  <p>Note that strcat() does not perform bounds checking, and thus
  risks overrunning <em>str1</em> or <em>str2</em>.  For a similar (and
  safer) function that includes bounds checking, see <a
  href="strncat.html">strncat()</a>.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="strchr.html">strchr</a><br>
    <a href="strcmp.html">strcmp</a><br>
    <a href="strcpy.html">strcpy</a><br>
    <a href="strncat.html">strncat</a>
  </div>

  <p>Another set of related (but non-standard) functions are <a
  href="http://en.wikipedia.org/wiki/Strlcpy">strlcpy and
  strlcat</a>.</p>

  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strchr
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  char *strchr( const char *str, int ch );
</pre>

  <p>The function strchr() returns a pointer to the first occurence of
  <em>ch</em> in <em>str</em>, or <strong>NULL</strong> if <em>ch</em>
  is not found.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="strcat.html">strcat</a><br>
    <a href="strcmp.html">strcmp</a><br>
    <a href="strcpy.html">strcpy</a><br>
    <a href="strlen.html">strlen</a><br>
    <a href="strncat.html">strncat</a><br>
    <a href="strncmp.html">strncmp</a><br>
    <a href="strncpy.html">strncpy</a><br>
    <a href="strpbrk.html">strpbrk</a><br>
    <a href="strspn.html">strspn</a><br>
    <a href="strstr.html">strstr</a><br>
    <a href="strtok.html">strtok</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strcmp
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  int strcmp( const char *str1, const char *str2 );
</pre>

  <p>The function strcmp() compares <em>str1</em> and <em>str2</em>,
  then returns:</p>

  <table class="code-table">
    <tr>
      <th class="code-table-th">Return value</th>

      <th class="code-table-th">Explanation</th>
    </tr>

    <tr>
      <td class="code-table-td">less than 0</td>

      <td class="code-table-td">&#39;&#39;str1&#39;&#39; is less than
      &#39;&#39;str2&#39;&#39;</td>
    </tr>

    <tr>
      <td class="code-table-td">equal to 0</td>

      <td class="code-table-td">&#39;&#39;str1&#39;&#39; is equal to
      &#39;&#39;str2&#39;&#39;</td>
    </tr>

    <tr>
      <td class="code-table-td">greater than 0</td>

      <td class="code-table-td">&#39;&#39;str1&#39;&#39; is greater
      than &#39;&#39;str2&#39;&#39;</td>
    </tr>
  </table>

  <p>For example:</p>
  <pre class="example-code">
   printf( &quot;Enter your name: &quot; );
   scanf( &quot;%s&quot;, name );
   if( strcmp( name, &quot;Mary&quot; ) == 0 ) {
     printf( &quot;Hello, Dr. Mary!\n&quot; );
   }        
</pre>

  <p>Note that if <em>str1</em> or <em>str2</em> are missing a
  null-termination character, then strcmp() may not produce valid
  results.  For a similar (and safer) function that includes explicit
  bounds checking, see <a href="strncmp.html">strncmp()</a>.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="memcmp.html">memcmp</a><br>
    <a href="strcat.html">strcat</a><br>
    <a href="strchr.html">strchr</a><br>
    <a href="strcoll.html">strcoll</a><br>
    <a href="strcpy.html">strcpy</a><br>
    <a href="strlen.html">strlen</a><br>
    <a href="strncmp.html">strncmp</a><br>
    <a href="strxfrm.html">strxfrm</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strcoll
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  int strcoll( const char *str1, const char *str2 );
</pre>

  <p>The strcoll() function compares <em>str1</em> and <em>str2</em>,
  much like <a href="strcmp.html">strcmp</a>(). However, strcoll()
  performs the comparison using the locale specified by the (Standard C
  Date &amp; Time) <a href="../stddate/setlocale.html">setlocale</a>()
  function.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    (Standard C Date &amp; Time) <a href=
    "../stddate/setlocale.html">setlocale</a><br>
    <a href="strcmp.html">strcmp</a><br>
    <a href="strxfrm.html">strxfrm</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strcpy
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  char *strcpy( char *to, const char *from );
</pre>

  <p>The strcpy() function copies characters in the string
  <em>from</em> to the string <em>to</em>, including the null
  termination. The return value is <em>to</em>.</p>

  <p>Note that strcpy() does not perform bounds checking, and thus
  risks overrunning <em>from</em> or <em>to</em>.  For a similar (and
  safer) function that includes bounds checking, see <a
  href="strncpy.html">strncpy()</a>.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="memcpy.html">memcpy</a><br>
    <a href="strcat.html">strcat</a><br>
    <a href="strchr.html">strchr</a><br>
    <a href="strcmp.html">strcmp</a><br>
    <a href="strncmp.html">strncmp</a><br>
    <a href="strncpy.html">strncpy</a>
  </div>

  <p>Another set of related (but non-standard) functions are <a
  href="http://en.wikipedia.org/wiki/Strlcpy">strlcpy and
  strlcat</a>.</p>

  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strcspn
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  size_t strcspn( const char *str1, const char *str2 );
</pre>

  <p>The function strcspn() returns the index of the first character in
  <em>str1</em> that matches any of the characters in
  <em>str2</em>.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="strpbrk.html">strpbrk</a><br>
    <a href="strrchr.html">strrchr</a><br>
    <a href="strstr.html">strstr</a><br>
    <a href="strtok.html">strtok</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strerror
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  char *strerror( int num );
</pre>

  <p>The function strerror() returns an implementation defined string
  corresponding to <em>num</em>.</p>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strlen
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  size_t strlen( char *str );
</pre>

  <p>The strlen() function returns the length of <em>str</em>
  (determined by the number of characters before null termination).</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="memcpy.html">memcpy</a><br>
    <a href="strchr.html">strchr</a><br>
    <a href="strcmp.html">strcmp</a><br>
    <a href="strncmp.html">strncmp</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strncat
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  char *strncat( char *str1, const char *str2, size_t count );
</pre>

  <p>The function strncat() concatenates at most <em>count</em>
  characters of <em>str2</em> onto <em>str1</em>, adding a null
  termination. The resulting string is returned.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="strcat.html">strcat</a><br>
    <a href="strchr.html">strchr</a><br>
    <a href="strncmp.html">strncmp</a><br>
    <a href="strncpy.html">strncpy</a>
  </div>

  <p>Another set of related (but non-standard) functions are <a
  href="http://en.wikipedia.org/wiki/Strlcpy">strlcpy and
  strlcat</a>.</p>

  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strncmp
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  int strncmp( const char *str1, const char *str2, size_t count );
</pre>

  <p>The strncmp() function compares at most <em>count</em> characters
  of <em>str1</em> and <em>str2</em>. The return value is as
  follows:</p>

  <table class="code-table">
    <tr>
      <th class="code-table-th">Return value</th>

      <th class="code-table-th">Explanation</th>
    </tr>

    <tr>
      <td class="code-table-td">less than 0</td>

      <td class="code-table-td">&#39;&#39;str1&#39;&#39; is less than
      &#39;&#39;str2&#39;&#39;</td>
    </tr>

    <tr>
      <td class="code-table-td">equal to 0</td>

      <td class="code-table-td">&#39;&#39;str1&#39;&#39; is equal to
      &#39;&#39;str2&#39;&#39;</td>
    </tr>

    <tr>
      <td class="code-table-td">greater than 0</td>

      <td class="code-table-td">&#39;&#39;str1&#39;&#39; is greater
      than str2&#39;&#39;</td>
    </tr>
  </table>

  <p>If there are less than <em>count</em> characters in either string,
  then the comparison will stop after the first null termination is
  encountered.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="strchr.html">strchr</a><br>
    <a href="strcmp.html">strcmp</a><br>
    <a href="strcpy.html">strcpy</a><br>
    <a href="strlen.html">strlen</a><br>
    <a href="strncat.html">strncat</a><br>
    <a href="strncpy.html">strncpy</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strncpy
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  char *strncpy( char *to, const char *from, size_t count );
</pre>

  <p>The strncpy() function copies at most <em>count</em> characters of
  <em>from</em> to the string <em>to</em>. If from has less than
  <em>count</em> characters, the remainder is padded with &#39;\0&#39;
  characters. The return value is the resulting string.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="memcpy.html">memcpy</a><br>
    <a href="strchr.html">strchr</a><br>
    <a href="strcpy.html">strcpy</a><br>
    <a href="strncat.html">strncat</a><br>
    <a href="strncmp.html">strncmp</a>
  </div>

  <p>Another set of related (but non-standard) functions are <a
  href="http://en.wikipedia.org/wiki/Strlcpy">strlcpy and
  strlcat</a>.</p>

  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strpbrk
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  char* strpbrk( const char* str1, const char* str2 );
</pre>

  <p>The function strpbrk() returns a pointer to the first ocurrence in
  <em>str1</em> of any character in <em>str2</em>, or
  <strong>NULL</strong> if no such characters are present.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    (C++ Algorithms) <a href=
    "../cppalgorithm/find_first_of.html">find_first_of</a><br>
    <a href="strchr.html">strchr</a><br>
    <a href="strcspn.html">strcspn</a><br>
    <a href="strrchr.html">strrchr</a><br>
    <a href="strspn.html">strspn</a><br>
    <a href="strstr.html">strstr</a><br>
    <a href="strtok.html">strtok</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strrchr
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  char *strrchr( const char *str, int ch );
</pre>

  <p>The function strrchr() returns a pointer to the last occurrence of
  <em>ch</em> in <em>str</em>, or <strong>NULL</strong> if no match is
  found.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="strcspn.html">strcspn</a><br>
    <a href="strpbrk.html">strpbrk</a><br>
    <a href="strspn.html">strspn</a><br>
    <a href="strstr.html">strstr</a><br>
    <a href="strtok.html">strtok</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strspn
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  size_t strspn( const char *str1, const char *str2 );
</pre>

  <p>The strspn() function returns the index of the first character in
  <em>str1</em> that doesn&#39;t match any character in
  <em>str2</em>.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="strchr.html">strchr</a><br>
    <a href="strpbrk.html">strpbrk</a><br>
    <a href="strrchr.html">strrchr</a><br>
    <a href="strstr.html">strstr</a><br>
    <a href="strtok.html">strtok</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strstr
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  char *strstr( const char *str1, const char *str2 );
</pre>

  <p>The function strstr() returns a pointer to the first occurrence
  of <em>str2</em> in <em>str1</em>, or <strong>NULL</strong> if no
  match is found.  If the length of <em>str2</em> is zero, then
  strstr() will simply return <em>str1</em>.
  </p>

  <p>For example, the following code checks for the existence of one
  string within another string:</p>

  <pre class="example-code">
  char* str1 = "this is a string of characters";
  char* str2 = "a string";
  char* result = strstr( str1, str2 );
  if( result == NULL ) printf( "Could not find '%s' in '%s'\n", str2, str1 );
  else printf( "Found a substring: '%s'\n", result );
</pre>

  <p>When run, the above code displays this output:</p>
  <pre class="example-code">
  Found a substring: 'a string of characters'
</pre>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="memchr.html">memchr</a><br>
    <a href="strchr.html">strchr</a><br>
    <a href="strcspn.html">strcspn</a><br>
    <a href="strpbrk.html">strpbrk</a><br>
    <a href="strrchr.html">strrchr</a><br>
    <a href="strspn.html">strspn</a><br>
    <a href="strtok.html">strtok</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strtod
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;stdlib.h&gt;
  double strtod( const char *start, char **end );
</pre>

  <p>The function strtod() returns whatever it encounters first in
  <em>start</em> as a double. <em>end</em> is set to point at whatever
  is left in <em>start</em> after that double. If overflow occurs,
  strtod() returns either <strong>HUGE_VAL</strong> or
  -<strong>HUGE_VAL</strong>.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="atof.html">atof</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strtok
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  char *strtok( char *str1, const char *str2 );
</pre>

  <p>The strtok() function returns a pointer to the next
  &quot;token&quot; in <em>str1</em>, where <em>str2</em> contains the
  delimiters that determine the token. strtok() returns
  <strong>NULL</strong> if no token is found. In order to convert a
  string to tokens, the first call to strtok() should have
  <em>str1</em> point to the string to be tokenized. All calls after
  this should have <em>str1</em> be <strong>NULL</strong>.</p>

  <p>For example:</p>
  <pre class="example-code">
   char str[] = &quot;now # is the time for all # good men to come to the # aid of their country&quot;;
   char delims[] = &quot;#&quot;;
   char *result = <strong>NULL</strong>;
   result = strtok( str, delims );
   while( result != <strong>NULL</strong> ) {
       printf( &quot;result is \&quot;%s\&quot;\n&quot;, result );
       result = strtok( <strong>NULL</strong>, delims );
   }            
</pre>

  <p>The above code will display the following output:</p>
  <pre class="example-code">
   result is &quot;now &quot;
   result is &quot; is the time for all &quot;
   result is &quot; good men to come to the &quot;
   result is &quot; aid of their country&quot;          
</pre>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="strchr.html">strchr</a><br>
    <a href="strcspn.html">strcspn</a><br>
    <a href="strpbrk.html">strpbrk</a><br>
    <a href="strrchr.html">strrchr</a><br>
    <a href="strspn.html">strspn</a><br>
    <a href="strstr.html">strstr</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strtol
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;stdlib.h&gt;
  long strtol( const char *start, char **end, int base );
</pre>

  <p>The strtol() function returns whatever it encounters first in
  <em>start</em> as a long, doing the conversion to <em>base</em> if
  necessary. <em>end</em> is set to point to whatever is left in
  <em>start</em> after the long. If the result can not be represented
  by a long, then strtol() returns either <strong>LONG_MAX</strong> or
  <strong>LONG_MIN</strong>. Zero is returned upon error.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="atol.html">atol</a><br>
    <a href="strtoul.html">strtoul</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strtoul
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;stdlib.h&gt;
  unsigned long strtoul( const char *start, char **end, int base );
</pre>

  <p>The function strtoul() behaves exactly like <a href=
  "strtol.html">strtol</a>(), except that it returns an unsigned long
  rather than a mere long.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="strtol.html">strtol</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    strxfrm
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  size_t strxfrm( char *str1, const char *str2, size_t num );
</pre>

  <p>The strxfrm() function manipulates the first <em>num</em>
  characters of <em>str2</em> and stores them in <em>str1</em>. The
  result is such that if a <a href="strcoll.html">strcoll</a>() is
  performed on <em>str1</em> and the old <em>str2</em>, you will get
  the same result as with a <a href="strcmp.html">strcmp</a>().</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="strcmp.html">strcmp</a><br>
    <a href="strcoll.html">strcoll</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    tolower
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;ctype.h&gt;
  int tolower( int ch );
</pre>

  <p>The function tolower() returns the lowercase version of the
  character <em>ch</em>.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="isupper.html">isupper</a><br>
    <a href="toupper.html">toupper</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>

  <div class="name-format">
    toupper
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;ctype.h&gt;
  int toupper( int ch );
</pre>

  <p>The toupper() function returns the uppercase version of the
  character <em>ch</em>.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="tolower.html">tolower</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
<hr>
</body></html>
